<?php
require_once ("./vue/vMain.php");

class VModif extends VMain{

	public function __construct() {
		parent::__construct();

		
		$sqlListeType = "SELECT * FROM TypeArticle";
		$reqListeType = mysql_query($sqlListeType) or die('Erreur SQL !<br />'.$sql2.'<br />'.mysql_error());
		$listeEntrepots = persistanceEntrepot::getAll();
		$listeSocietes = persistanceSociete::getAll();

		//Ajouter un article

		echo "<h2 class=\"title\">Ajouter un article</h2><br>";
		echo "<form action='index.php?do=modifier' method='post'>";
		echo "<br /><br />Type :";
		echo "<select name='listeType'>";
		echo "<option value='defaut'></option>";
		while ($row=mysql_fetch_array($reqListeType)) {
			echo "<option value='";
			echo $row['idType'];
			echo "'>";
			echo $row['nomType'];
			echo " - ";
			echo $row['modele'];
			echo "</option>";
		}
		echo "</select><br /><br />";

		echo "   Numero de s&eacute;rie : ";
		echo "<input type='text' name='numeroSerie' size='5' maxlength='5' /><br><br />";

		echo "  Entrepot :";
		echo "<select name='listeEntrepot'>";
		echo "<option value='defaut'></option>";
		for ($i=0 ; $i < sizeof($listeEntrepots); $i++) {
			echo "<option value='";
			echo $listeEntrepots[$i]['idSite'];
			echo "'>";
			echo $listeEntrepots[$i]['nomSite'];
			echo "</option>";
		}
		echo "</select><br /><br />";

		echo "  Fournisseur :";
		echo "<select name='listeFournisseur'>";
		echo "<option value='defaut'></option>";
		for ($i=0 ; $i < sizeof($listeSocietes); $i++) {
			echo "<option value='";
			echo $listeSocietes[$i]['idSociete'];
			echo "'>";
			echo $listeSocietes[$i]['nomSociete'];
			echo "</option>";
		}
		echo "</select><br /><br />";

		echo "Jour :";
		echo "<select name='day'>";
		echo "<option value='defaut'></option>";
		for ($i =1 ; $i < 32 ; $i++) {
			echo "<option value='";
			echo substr("0".$i,-2);;
			echo "'>";
			echo substr("0".$i,-2);;
			echo "</option>";
		}
		echo "</select>";
		echo "Mois :";
		echo "<select name='month'>";
		echo "<option value='defaut'></option>";
		for ($i =1 ; $i < 13 ; $i++) {
			echo "<option value='";
			echo substr("00".$i,-2);
			echo "'>";
			echo substr("0".$i,-2);;
			echo "</option>";
		}
		echo "</select>";
		echo "Ann&eacute;e :";
		echo "<select name='year'>";
		echo "<option value='defaut'></option>";
		for ($i =2000 ; $i < 2013 ; $i++) {
			echo "<option value='";
			echo $i;
			echo "'>";
			echo $i;
			echo "</option>";
		}
		echo "</select><br /><br />";

		echo "<input type='hidden' name='ajouterArticle' value='ok'>";
		echo "<input type='submit' name='ajoutArticle' size='10' value='Valider'>";
		echo "</form>";


		//Supprimer un article

		echo "<br/><br/>";
		echo "<h2 class=\"title\">Sortir un article </h2>";
		echo "<form action='index.php?do=modifier' method='post'>";

		echo "<br /><br />Numero de s&eacute;rie : ";
		echo "<input type='text' name='numeroSerie' size='5' maxlength='5' /><br /><br />";

		echo "  Client :";
		echo "<select name='client'>";
		echo "<option value='defaut'></option>";


		for ($i=0 ; $i < sizeof($listeSocietes); $i++) {
			echo "<option value='";
			echo $listeSocietes[$i]['idSociete'];
			echo "'>";
			echo $listeSocietes[$i]['nomSociete'];
			echo "</option>";
		}

		echo "</select><br /><br />";

		echo "Jour :";
		echo "<select name='day'>";
		echo "<option value='defaut'></option>";
		for ($i =1 ; $i < 32 ; $i++) {
			echo "<option value='";
			echo substr("0".$i,-2);;
			echo "'>";
			echo substr("0".$i,-2);;
			echo "</option>";
		}
		echo "</select>";
		echo "Mois :";
		echo "<select name='month'>";
		echo "<option value='defaut'></option>";
		for ($i =1 ; $i < 13 ; $i++) {
			echo "<option value='";
			echo substr("00".$i,-2);
			echo "'>";
			echo substr("0".$i,-2);;
			echo "</option>";
		}
		echo "</select>";
		echo "Ann&eacute;e :";
		echo "<select name='year'>";
		echo "<option value='defaut'></option>";
		for ($i =2000 ; $i < 2013 ; $i++) {
			echo "<option value='";
			echo $i;
			echo "'>";
			echo $i;
			echo "</option>";
		}
		echo "</select><br /><br />";

		echo "<input type='hidden' name='supprimerArticle' value='ok'>";
		echo "<input type='submit' name='supprAriticle' size='10' value='Valider'>";
		echo "</form>";

		//Modifier l'entrepot d'un article

		echo "<br/><br/>";
		echo '<h2 class="title">Modifier l\'entrepot d\'un article </h2>';
		echo "<form action='index.php?do=modifier' method='post'>";

		echo " <br /><br />Numero de s&eacute;rie : ";
		echo "<input type='text' name='numeroSerie' size='5' maxlength='5' /><br /><br />";

		echo "  Entrepot :";
		echo "<select name='entrepot'>";
		echo "<option value='defaut'></option>";
		for ($i=0 ; $i < sizeof($listeEntrepots); $i++) {
			echo "<option value='";
			echo $listeEntrepots[$i]['idSite'];
			echo "'>";
			echo $listeEntrepots[$i]['nomSite'];
			echo "</option>";
		}
		echo "</select><br /><br />";

		echo "Jour :";
		echo "<select name='day'>";
		echo "<option value='defaut'></option>";
		for ($i =1 ; $i < 32 ; $i++) {
			echo "<option value='";
			echo substr("0".$i,-2);;
			echo "'>";
			echo substr("0".$i,-2);;
			echo "</option>";
		}
		echo "</select>";
		echo "Mois :";
		echo "<select name='month'>";
		echo "<option value='defaut'></option>";
		for ($i =1 ; $i < 13 ; $i++) {
			echo "<option value='";
			echo substr("00".$i,-2);
			echo "'>";
			echo substr("0".$i,-2);;
			echo "</option>";
		}
		echo "</select>";
		echo "Ann&eacute;e :";
		echo "<select name='year'>";
		echo "<option value='defaut'></option>";
		for ($i =2000 ; $i < 2013 ; $i++) {
			echo "<option value='";
			echo $i;
			echo "'>";
			echo $i;
			echo "</option>";
		}
		echo "</select><br /><br />";

		echo "<input type='hidden' name='modifierSite' value='ok'>";
		echo "<input type='submit' name='modifierEntrepot' size='10' value='Valider'>";
		echo "</form>";

	}
}